﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HPortal.Lib;
using System.Collections;

public partial class Module_Menu_YMenuTop : System.Web.UI.UserControl
{

    DataTable tbChannel = new DataTable();
    DataTable tbChannelID = new DataTable();
    String menu = "";
    public String ChannelID = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        //String sqlGetChannelID ="Select ChannelID From Channel where PanelID='" + this.PanelID + "'").Rows[0]["ChannelI"].ToString();
        //ChannelID = DatabaseHelper.Select(sqlGetChannelID);
        //PageID = BaseDAO.Execute_AnyQuery("Select PageID From Panels where PanelID='" + this.PanelID + "'").Rows[0]["PageID"].ToString();

       // Response.Write(" <link href=\"../../Content/ND_DS_LoaiSP_MenuLeft.css\" rel=\"stylesheet\" type=\"text/css\" />");
        GetChannel("");
        menu += "<li><a href = \"/Backend\">Quản lý</a><ul></ul></li>";
        menu = menu.Replace("<ul></ul>", "");
        category.Text = "<ul class=\"sf-menu\">" + menu + "</ul>";
    }

    public String GetChannel(String PrentID)
    {
        String sql = "Select * from Channel where ParentID = '" + PrentID + "' and Locked='False' order by Priority ASC";
        DataTable tbChannel = DatabaseHelper.Select(sql);
        int i = 0;

        while (i < tbChannel.Rows.Count)
        {
            //menu += "<li><a href = \"/HPortal/Default.aspx?ChannelID=" + tbChannel.Rows[i]["ChannelID"].ToString() + "\">" + tbChannel.Rows[i]["Name"] + "</a><ul>";
            menu += "<li><a href = \"/Default.aspx?ChannelID=" + tbChannel.Rows[i]["ChannelID"].ToString() + "\">" + tbChannel.Rows[i]["Name"] + "</a><ul>";
            GetChannel(tbChannel.Rows[i]["ChannelID"].ToString());
            menu += "</ul></li>";
            i++;
        }
        return menu;
    } 
}